// Package generics
// Created by GoLand
// @User: lenora
// @Date: 2023/11/26
// @Time: 18:09

package generics

//Max
//泛型方法
func Max[T Number](group []T) T {
	if len(group) <= 0 {
		panic("length error")
	}
	if len(group) == 1 {
		return group[0]
	}
	max := group[0]
	for i := 1; i < len(group); i++ {
		if group[i] <= max {
			continue
		}
		max = group[i]
	}
	return max
}

type Integer int

type Number interface {
	~int | uint | int8
}

func UseMax() {
	println(Max[Integer]([]Integer{}))

	fa := make([]int, 0, 4)
	k := append(fa, 1, 2)
	println(k)
}
